package com.ruoyi.web.controller.applet;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.OperatorType;
import com.ruoyi.system.domain.dto.BindUserDto;
import com.ruoyi.system.service.IBdmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 用户Controller
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/applet/userQRCode")
public class AppletUserQRCodeController extends BaseController {
    @Autowired
    private IBdmUserService bdmUserService;

    /**
     * 生成用户二维码
     * @param bindUserDto
     * @param response
     */
    @Log(title = "生成用户二维码", businessType = BusinessType.EXPORT, operatorType = OperatorType.MOBILE)
    @GetMapping(value = "/createUserQR")
    public void createUserQR(BindUserDto bindUserDto, HttpServletResponse response) {
        bindUserDto.setDomain("https://lm.bwmonlinestore.com");
        bdmUserService.createUserQRCode(bindUserDto, response);
    }

    /**
     * 绑定用户关系
     * @param bindUserDto 绑定用户
     */
    @GetMapping(value = "/bindRelation")
    public AjaxResult bindRelation(BindUserDto bindUserDto) {
        return toAjax(bdmUserService.bindUser(bindUserDto));
    }
}
